<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
//use Illuminate\Http\Request;
class ManagerRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'      => 'required',
            'username'  => 'required|unique:users,username',
            'email'    => 'required|email|max:255|unique:users,email',
            'password'  => 'required|min:6|confirmed'
        ];
//        $rules['name'] = 'required';
//        $rules['password'] = 'required|min:6|confirmed';
//        if( request('id','') ){
//            $rules['username']  = 'required|unique:users,username,'.$this->id;
//            $rules['email'] = 'required|email|max:255|unique:users,email,'.$this->id;
//        }else{
//            $rules['username']  = 'required|unique:users,username';
//            $rules['email'] = 'required|email|max:255|unique:users,email';
//        }
//        return $rules;
    }
}
